<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="root"></div>
</body>

</html>
<script src="https://unpkg.com/vue@next"></script>
<script>
    // 自定义指令 derective
    const app = Vue.createApp({
        data(){
            return{
                hello:true,
            }
        },
        template: `
        <div>
            <div v-if="hello">
                <input v-focus />
            </div>
        </div>
        `
    })
    app.directive('focus',{
        beforeMount(el){
            console.log('beforeMount');
        },
        mounted(el){
            console.log('mounted');
        },
        beforeUpdate(el){
            console.log('beforeUpdate');
        },
        updated(el){
            console.log('updated');
        },
        beforeUnmount(el){
            console.log('beforeUnmount');
        },
        unmounted(el){
            console.log('unmounted');
        },
    })
    const vm = app.mount('#root')
</script>